<div id="basicListing">
<h1>Events by Date Range: <%= @dateFrom.strftime("%A (%m/%d/%Y)") %> to <%= @dateTo.strftime("%A (%m/%d/%Y)") %></h1>
<span id="printThis">
<% form_tag(:controller => "reports", :action => "byrange", :id => @user) do %>
<%= select_date(@dateFrom, :prefix => 'dateFrom') %> to <%= select_date(@dateTo, :prefix => 'dateTo') %>
<%= submit_tag 'Update Range' %>
<% end %>
<%= link_to_function(image_tag("print.png",:border => 0), "javascript:print()") %></span>

<% @traces_by_day_this_week.each do |day,traces| %>
  <% @minToday = traces.sum(&:minSpent) %>
  <% @sortedDay = traces.sort! {|x,y| x.event_id <=> y.event_id } %>
  <% @groupedTraces = @sortedDay.group_by{|e| e.event} %>
  
  <table border=0>
    <tr><th colspan=3 align="left"><%= day.strftime("%A (%m/%d/%Y)") %></th></tr>
     
      <% @groupedTraces.each do |eventThisDay,tracesThisEvent| %>
        <% @minThisEvent = tracesThisEvent.sum(&:minSpent) %>
        <tr>
        <td width="30%"><%= eventThisDay.title %> (<%= eventThisDay.ticketNumber %>)</td>
        <td width="20%"><%= "%02d:%02d" % [(@minThisEvent / 60),(@minThisEvent % 60)] %></td>
        <td width="50%" align="left"><%= (@minThisEvent.to_f/60).round(2) %></td>
        </tr>
      <% end %>
      
      <tr>
        <td width="20%" align="right">Total:</td>
        <td width="80%" align="left" colspan="2"><%= "%02d:%02d" % [(@minToday / 60),(@minToday % 60)] %></td>
      </tr>
  </table>
<% end %>

</div>